package com.zbl.zblproject.pay.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zbl.zblproject.core.entity.AdminUser;
import com.zbl.zblproject.pay.entity.PayOrder;
import com.zbl.zblproject.pay.entity.PayOrderItem;
import com.zbl.zblproject.pay.entity.StatisticsTable;
import com.zbl.zblproject.pay.vo.PayOrderItemVo;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/11/5
 */
public interface PayService {

    /**
     * 将订单信息录入数据库
     * @param user 用户
     * @param order 订单
     * @return  创建成功 或 创建失败
     */
    void createBaseOrder(AdminUser user, PayOrder order);

    /**
     * 将订单信息录入数据库 第2次
     * @param user 用户
     * @param order 订单
     * @return  创建成功 或 创建失败
     */
    void createBaseOrderTwo(AdminUser user, PayOrder order);


    /**
     * 创建批量订单
     * @param user
     * @param orders
     */
    List<String> createBaseOrders(String sn, AdminUser user, List<PayOrder> orders);

    /**
     * 创建批量订单 第2次
     * @param user
     * @param orders
     */
    List<String> createBaseOrdersRepetition(String sn, AdminUser user, List<PayOrder> orders);

    void subtract(List<PayOrderItem> items);

    /**
     * 支付宝订单
     * @param order
     * @return
     */
    String alipay(AdminUser user, PayOrder order);



    /**
     * 支付宝订单第2次
     * @param order
     * @return
     */
    String alipayTwo(AdminUser user, PayOrder order);

    /**
     * 微信订单
     * @param order
     * @return
     */
    void weixin(AdminUser user, PayOrder order);

    /**
     * 微信订单 第2次
     * @param order
     * @return
     */
    void weixinTwo(AdminUser user, PayOrder order);


    /**
     * 银联订单
     * @param order
     * @return
     */
    void union(AdminUser user, PayOrder order);

    PayOrder getOrderByOnlineSn(String orderSn);

    /**
     * 订单退款
     * @param order
     * @return
     */
    boolean changeOrderToRefund(PayOrder order);

    /**
     * 退款 退部分商品
     * @param order
     * @return
     */
    BigDecimal returnAlipayItems(PayOrder order, List<PayOrderItem> list);


    String getPayOrderOnlineOrder(String orderSn);

    /**
     * 今天交易成功的订单
     * @return
     */
    JSONArray todaySuccessPayOrders(String orderSn, int userId);

    /**
     * 订单详情
     * @param orderSn
     * @return
     */
    JSONObject payOrderInfo(String orderSn);

    JSONObject  salesPage(LocalDateTime start, LocalDateTime end, int useId, String goodsName, int catId, int supId);

    JSONObject pageForOrderList(LocalDateTime start, LocalDateTime end, int useId, int current, int size, int mode);


    void synOrder(List<PayOrder> orders);

    /**
     * 获取对应用户的统计报表
     * @return
     */
    List<StatisticsTable> getStatisticsTable(LocalDateTime start, LocalDateTime end, Integer userId);
}